package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents a situation when a client joins 
 * an existing table. This message is received by the table's 
 * owner.
 */
public class CommandJoinTableToOwner implements ITransmittable {

	private final static String ATTR_USER_NAME = "Username";
	
	private String username = null; 
	
	
	public CommandJoinTableToOwner (String username) {
		this.username = username;
	}
	
	public CommandJoinTableToOwner (XMLElement command) {
		this((String)command.getAttribute(ATTR_USER_NAME));
	}
	
	
	@Override
	public XMLElement toXML() {
		XMLElement message  = new XMLElement();
		message.setName(Commands.JOIN_TABLE_TO_OWNER);
		message.setAttribute(ATTR_USER_NAME, username);
		return message;
	}
	
	public String getUsername()
	{
		return username;
	}
}
